package com.wzy.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * 流程实例的启动,前提 已经完成流程定义的部署工作
 * 执行后影响的表:
 */
public class ActivitiStartInstance {
    public static void main(String[] args) {
        //1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到Runservice对象
        RuntimeService runtimeService = processEngine.getRuntimeService();
        //3.创建流程实例,需要知道流程定义的key
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_1");
        //4.输出实例的相关信息
        System.out.println("流程部署的ID:" + processInstance.getDeploymentId());
        System.out.println("流程定义的ID:" + processInstance.getProcessDefinitionId());
        System.out.println("流程实例的ID:" + processInstance.getId());
        System.out.println("活动ID;" + processInstance.getActivityId());

    }

}
